package com.qf.commons.core.utils;

/**
 * author Ken
 * create_time 2022/9/22
 */
public class CommonsUtils {

    /**
     * 根据id 返回一个4位长度的字符串  5 -> 0005  18 -> 0018
     * @param id
     * @return
     */
    public static String id2Str(Integer id, Integer ws){
        String sid = id + "";
        if(sid.length() > ws){
            return null;
        }

        int len = sid.length();
        for(int i = 0; i < ws - len; i++){
            sid = "0" + sid;
        }
        return sid;
    }
}
